﻿using BrokenCalculator.Enum;

namespace BrokenCalculator;

public class Converter
{
    public static Double Degrees(Double angle, Units angleUnit)
    {
        if (angleUnit == Units.Radians) return angle * 180 / Math.PI;
        if (angleUnit == Units.Gradians) return angle * 9 / 10;
        if (angleUnit == Units.Degrees) return angle;
        Exception error = new Exception("Invalid parameters");
        throw error;
    }

    public static Double Radians(Double angle, Units angleUnit)
    {
        if (angleUnit == Units.Radians) return angle;
        
        return Degrees(angle, angleUnit) * Math.PI / 180;
    }

    public static Double Gradians(Double angle, Units angleUnit)
    {
        if (angleUnit == Units.Gradians) return angle;

        return Degrees(angle, angleUnit) * 10 / 9;
    }
}